<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$return['pluginset']=$this->areasetting;
if($_RQ['op']=='main'){
	$return['setting']=$this->plugin_setting('areapage');
	$return['setting']['balance_money']=$this->areasetting['balance_money'];
	$data=array();
	$data['commission_total']=$this->sum('commission',array('mid'=>$_SESSION['uid'],'type'=>array(3,4,5,6,7)),'jifen');
	$data['commission_0']=$this->sum('commission',array('mid'=>$_SESSION['uid'],'status'=>0,'type'=>array(3,4,5,6,7)),'jifen');
	//待结算佣金
	$data['commission_1']=$this->sum('commission',array('mid'=>$_SESSION['uid'],'status'=>1,'type'=>array(3,4,5,6,7)),'jifen');
	//可结算佣金
	$params=array('mid'=>$_SESSION['uid'],'status'=>1,'type'=>array(3,4,5,6,7));
	if($this->areasetting['balance_day']){
		//结算天数
		$time=TIMESTAMP-intval($this->areasetting['balance_day'])*86400;
		$params['complete_time <']=$time;
	}
	$data['commission_1_1']=$this->sum('commission',$params,'jifen');
	$data['balance_total']=$this->sum('balance',array('mid'=>$_SESSION['uid'],'type'=>1),'money');
	$data['balance_1']=$this->sum('balance',array('mid'=>$_SESSION['uid'],'status'=>1,'type'=>1),'money');
	$data['balance_2']=$this->sum('balance',array('mid'=>$_SESSION['uid'],'status'=>2,'type'=>1),'money');
	$data['balance_3']=$this->sum('balance',array('mid'=>$_SESSION['uid'],'status'=>3,'type'=>1),'money');
	foreach($data as &$row){
		$row=price($row);
	}
	$return['data']=$data;
	exi($return);
}
//结算
if($_RQ['op']=='balance'){
	exi('统一平台定时释放！','error');
	$this->model('area/commission')->create_balance($_SESSION['uid']);
	exi('结算成功！','','main');
}
?>